'''
Created on Oct 31, 2012

@author: petrina
'''
from link_indicator import Link_indicator
from indiutils import Indiutils
import logging

class Stddev_observed(Link_indicator):
    '''
    calculates the standard deviation of observed values (reference data) for every time interval.
    
    unit: index value
    '''


    def __init__(self, link):
        '''        
        @param link: Link-object (containing valid records and reference) 
        '''
        
        Link_indicator.__init__(self, link)
        
        self._name = 'Standard Deviation Observed Values'
        self._mr_name =  'stddev_observed'
        self._unit = 'index'
        #self.unit.__doc__ = 'index value'

        self._create_title(link.id, link.direction)
        
        logging.debug("Stddev_observed: created new Stddev_observed")
        
        
    #----------------------public methods of the class-------------------------
    
    def calculate(self):
        '''
        calculates the standard deviation of observed values
        '''
        
        logging.info("Stddev_observed: staring to calculate the Stddev_observed")

        utils = Indiutils()
        self._values = utils.calc_stddev_of(self._link.reference,"speed")

        logging.info("Stddev_observed: finished calculating the Stddev_observed")
        
        return self._values
           